class ExoTableau
{
	public static void affichage(int[] tab)
	{
		for (int i=0; i<tab.length; i++)
			System.out.print(tab[i]+" ");
		System.out.println("");
	}

	public static double moyenne(int[] tab)
	{
		return somme(tab)/(double)tab.length;
	}

	public static int somme(int[] tab)
	{
		int ret = 0;
		for (int i=0; i<tab.length; i++)
			ret += tab[i];
		return ret;
	}

	public static int[] zipSomme(int[] tab, int[] tab2)
	{
		int[] ret = new int[tab.length];
		for (int i=0; i<tab.length; i++)
			ret[i] = tab[i] + tab2[i];
		return ret;
	}

	public static double[] zipMoyenne(int[] tab, int[] tab2)
	{
		double[] ret = new double[tab.length];
		for (int i=0; i<tab.length; i++)
			ret[i] = (tab[i] + tab2[i]) / 2.0;
		return ret;
	}

	public static boolean ordered(int[] tab)
	{
		if (tab.length < 2)
			return true;
		else
		{
			int i=0, f=tab[0];
			//Skip constants
			while (tab[i]==f) i++;
			i--;
			//Already at the end?
			if (i==tab.length-1) return true;
			//First
			boolean croiss = (tab[i]<=tab[i+1]);
			for (; i<tab.length-1; i++)
				if (tab[i]<=tab[i+1] && !croiss)
					return false;
			return true;
		}
	}

	public static int max(int[] tab)
	{
		//tab can't be empty
		int ret = tab[0];
		for (int i=1; i<tab.length; i++)
			if (tab[i] > ret) ret = tab[i];
		return ret;
	}

	public static void main(String[] args)
	{
		int tab[] = new int[20];
		for (int i=0; i<20; i++)
			tab[i] = (int)Math.pow(2, i);

		int tab2[] = new int[20];
		for (int i=0; i<20; i++)
			tab2[i] = (20-i)*2-1;

		int tab3[] = new int[20];
		for (int i=0; i<20; i++)
			tab3[i] = (int)Math.pow(-1, i) * i;

		for (int i=0; i<20; i++)
			System.out.println(tab[i]+"\t"+tab2[i]+"\t"+tab3[i]);

		if (ordered(tab)) System.out.println("tab ordered");
		if (ordered(tab2)) System.out.println("tab2 ordered");
		if (ordered(tab3)) System.out.println("tab3 ordered");

		System.out.println("tab max "+max(tab));
		System.out.println("tab2 max "+max(tab2));
		System.out.println("tab3 max "+max(tab3));
	}
}
